Skip to content

Formatting Conventions

Formatting Conventions

This book and supporting materials use the following formatting conventions:

Web Address

Web address will be shown as:

https://github.com/ProfessorKazarinoff/Problem-Solving-101-with-Python

Import terms and vocabulary

Important terms and vocabulary are shown in italic text

There is a difference between local variables and global variables in Python code

File Names

File Names are shown in bold and italic text

After completing the code, save the file as hello.py in the current directory.

Module and Package Names

Module and Package names will be shown in capital letters.

NumPy and Matplotlib are two useful Python packages for problem solvers

Inline code

Inline code including variable names is shown in monospace font

To compare a variable use var == 'string' and make sure to include ==, the double equals sign

Seperate code blocks

Separate code blocks will appear in their own areas in monospaced font

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

Terminal and Anaconda Prompt Commands

Commands typed into the terminal or Anaconda Prompt will be in seperate boxes which contain $ the dollar sign before each line. Note the $ dollar sign should not be typed. It is included to indicate the terminal or Anaconda prompt, not a character for the user to enter.

$ conda creat -n newenv python=3.6
$ conda activate newenv

Python REPL Commands

Commands typed into the Python REPL, also called the Python Interpreter, are shown in separate code boxes containg >>> the triple arrow prompt. Note the triple arrow sign >>> should not be typed. The triple arrow prompt is included to indicate the Python REPL prompt, not a character for the user to enter. The output from the Python REPL is shown on a separate line below the command, without the >>> prompt.

>>> 2 + 2
4
>>> print('Python for Undergraduate Engineers')
Python for Undergraduate Engineers

Jupyter Notebook cells

Commands typed into Jupyter Notebook cells appear with a label In [#]: and Out [#]: in front of a separate code block. Output from a jupyter notebook cell will be shown after the input cell. When typing the code examples into a jupyter notebook, only copy the code in the input cells. The output cells will be produced automatically when the run button is clicked or the user types [shift]+[Enter]

In [1]:
A = 2
B = 3
C = A + B
print(C)

5